package com.ruoyi.web.controller.tzzl;

import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.tzzl.domain.WzUserStandard;
import com.ruoyi.tzzl.service.IWzUserStandardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 用户择偶标准Controller
 * @author by caoyong
 * @date 2022/11/19
 **/
@RestController
@RequestMapping("/tzzl/standard")
public class WzUserStandardController extends BaseController {


    @Autowired
    private IWzUserStandardService wzUserStandardService;


    /**查看用户择偶标准*/
   @GetMapping("/query")
   public AjaxResult query(Long id){
       return AjaxResult.success(wzUserStandardService.getById(id));
   }

    /**修改用户择偶标准*/
    @PostMapping("/updateStandard")
    public AjaxResult updateStandard(@RequestBody WzUserStandard wzUserStandard){

        if (ObjectUtils.isNotEmpty(wzUserStandardService.getById(wzUserStandard.getId()))){
            return AjaxResult.success(wzUserStandardService.updateById(wzUserStandard));
        }else{
            return AjaxResult.success(wzUserStandardService.save(wzUserStandard));
        }
    }


}
